/*
 * @copyright: Huang Ding
 * @Author: ding-cx
 * @Date: 2020-12-02 16:22:03
 * @LastEditors: ding-cx
 * @LastEditTime: 2020-12-15 16:59:18
 * @Description: file content
 */
/* eslint valid-jsdoc: "off" */

'use strict';

/* ding admin系统配置 */
const dingConfig = require('./ding.config')

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1606897272265_6400';

  // add your middleware config here
  config.middleware = ["mwjwt"];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
    ...dingConfig
  };

  /* 日志配置 */
  config.logger = {
    dir: "./logs_prod",
    outputJSON: false,//输出json日志，方便做日志监控
  }

  /* jwt plugin */
  config.jwt = {
    secret: "fhsldghwoeihgtiowehrlgsdhfsljl24234hldkfsdfhls",
    expires: "1m",//jwt token过期时间
  }

  //内置安全插件配置
  config.security = {
    csrf: {
      queryName: '_csrf', // 通过 query 传递 CSRF token 的默认字段为 _csrf
      bodyName: '_csrf', // 通过 body 传递 CSRF token 的默认字段为 _csrf
      cookieName:"eggCsrfCookieName",
      headerName:'ding-admin-x-csrf-token',
    }
  }

  return {
    ...config,
    ...userConfig,
  };
};